
var menuWin2;
$(function () {
    menuWin2 = $("#infoOpenWindow").window({
        width: '650',
        height: '450',
        modal: true,
        collapsible: true,
        shadow: false,
        inline: false,
        closed: true,
        minimizable: false,
        maximizable: false,
        resizable: true
    })


})


function createWin() {
    var idArr = [];
    idArr.push("11110");
    idArr.push("11111");
    idArr.push("11112");
    idArr.push("11113");
    menuWin2.window({
        title: '编辑',
        href: '/batch/menuMod?ids='+idArr
    })
    menuWin2.window('open').window('refresh');
}

function closeMenuWin() {
    $("#infoOpenWindow").window('close');
}

    function changeSettleAmt(errnum, m) {
    alert(errnum)
        var settleAmtAdjust = $("#settleAmtAdjust" + errnum).val();
        if (parseInt(settleAmtAdjust) >= 0) {
            settleAmtAdjust = "+" + settleAmtAdjust;
        }
        var settleAmt = m + '' + settleAmtAdjust;
        $("#settleAmt" + errnum).val(settleAmt);
    }

    function changeAmt(errnum, m) {
        alert(errnum)
        var AmtAdjust = $("#AmtAdjust" + errnum).val();
        if (parseInt(AmtAdjust) >= 0) {
            AmtAdjust = "+" + AmtAdjust;
        }
        var Amt = m + '' + AmtAdjust;
        $("#Amt" + errnum).val(Amt);
    }

function saveWin() {
    var resultList =  $("#listVal").val();
    var errList =  JSON.parse(resultList).diffList1;

    var list = new Array();
    for (var errnum = 0; errnum < errList.length; errnum++) {
        var obj = new Object();
        obj.mappId = errList[errnum].mappId;
        obj.orgId = errList[errnum].orgId;
        obj.mchntNo = errList[errnum].mchntNo;
        var settleAmtAdjust = $("#settleAmtAdjust" + errnum).val();
        if (settleAmtAdjust === null || settleAmtAdjust === "") {
            settleAmtAdjust = "0";
        }
        obj.settleAmtAdjust = settleAmtAdjust;
        obj.settleAmt = parseInt(errList[errnum].settleAmt) + parseInt(settleAmtAdjust);

        var AmtAdjust = $("#AmtAdjust" + errnum).val();
        if (AmtAdjust === null || AmtAdjust === "") {
            AmtAdjust = "0";
        }
        obj.AmtAdjust = AmtAdjust;
        obj.Amt = parseInt(errList[errnum].Amt) + parseInt(AmtAdjust);


        obj.remark = $("#remark" + errnum).val();
        obj.operator = $("#operator" + errnum).val();
        list.push(obj);
    }

    $.ajax({  // ajax登陆请求
        url: "/batch/update",
        type: "POST",
        data: {params: JSON.stringify(list)},
        async: false,
        success: function (data) {
            if (data.result) {
                alert("success");
            } else {
                alert(data.msg);
            }
        }
    });

}

